Ext.regModel('E_Mail', {
	fields : [ 
	{		
		name : 'pageIndex',
		type : 'int'
	}, {		
		name : 'sender',
		type : 'string'
	}, {
		name : 'subject',
		type : 'string'
	}, {
		name : 'attachment',
		type : 'string'
	}, {
		name : 'receivedDate',
		type : 'string'
	} ]
});

// 4. 데이터 접근.
function mailData()
{
    // 데이터 읽기.
    var record              = mailStore.getAt(0);   
    console.log(record);   
    console.log(record.data.id);
    console.log(record.data.firstName);
    console.log(record.data["lastName"]);
}

var objStoreListener = {
	add : function() {
		console.log("add");
	},
	beforeload : function() {
		console.log("beforeload");
	},
	datachanged : function() {
		console.log("datachanged");
	},
	exception : function() {
		console.log("exception");
	},
	load : function() {
		console.log("load");
	},
	remove : function() {
		console.log("remove___");
	},
	update : function() {
		console.log("loadexception");
	}
}

var mailProxy = new Ext.data.AjaxProxy({
//	url: 'http://192.168.0.74:8080/simple-webapp/json', 안된다.... 이유는 모르겠다
	url: '../readJsonMail.do',
    type:'ajax',
    model: 'E_Mail',
    reader:{
        type:'json',
        root:'result'
    }
});

// 3. Store생성.
var mailStore = new Ext.data.JsonStore({
	model : 'E_Mail',
	encode: 'true',
    proxy: mailProxy
});
mailStore.sort('receivedDate', 'DESC');
mailStore.load();

var mailList = new Ext.List( {
	fullscreen : true,
	store : mailStore,
	itemTpl : '<div class="mail_service">{sender}||<strong>{subject}</strong>||{receivedDate}</div>'
} );